//
//  XyUpperLimitSettingViewController.m
//  JiuLe
//
//  Created by xcq on 15/11/9.
//  Copyright (c) 2015年 Fine. All rights reserved.
//
#define kMl @"ml"
#import "XyUpperLimitSettingViewController.h"

@interface XyUpperLimitSettingViewController ()
@property (weak, nonatomic) IBOutlet UIImageView *peugeotImg;
@property (weak, nonatomic) IBOutlet UISlider *slider;
@property (weak, nonatomic) IBOutlet UILabel *minValue;
@property (weak, nonatomic) IBOutlet UILabel *maxValue;
@property (weak, nonatomic) IBOutlet UILabel *currenValue;
@property (weak, nonatomic) IBOutlet UIButton *save;
@property (weak, nonatomic) IBOutlet UIView *valueView;
@property (assign, nonatomic) CGFloat currenValueInt;
@end

@implementation XyUpperLimitSettingViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self showNavBarWithRightTitle:nil
                    andRightAction:nil
                     andLeftAction:@selector(backTo)
                 andRightBtnIsShow:NO];
    [self setUp];
}

- (void)setUp {
    
    _currenValue.text=[[NSString stringWithFormat:@"%.0f",_xy] stringByAppendingString:_unit];
    _save.layer.cornerRadius = 20.f;
    
    _slider.value = _xy / _maxXy;
    
    _valueView.layer.shadowColor = [UIColor grayColor].CGColor;
    _valueView.layer.shadowOffset = CGSizeMake(0, 1);
    _valueView.layer.shadowOpacity = 0.8;
    _valueView.layer.shadowPath = [UIBezierPath bezierPathWithRect:CGRectMake(0, 199, CGRectGetWidth(_valueView.frame), 1)].CGPath;
    
    _minValue.text = [NSString stringWithFormat:@"%.0f",_minXy];
    _maxValue.text = [NSString stringWithFormat:@"%.0f",_maxXy];
    
    if ([_typeName isEqualToString:@"血氧"]) {
        _setName.text = @"血氧";
        _peugeotImg.image = [UIImage imageNamed:@"xueyang_ico"];
    } else {
        _setName.text = @"心率";
         _peugeotImg.image = [UIImage imageNamed:@"xinlv_ico"];
    }
}

- (IBAction)sliderValueChange:(id)sender {
    CGFloat value = _slider.value;
    _currenValueInt = value *_maxXy;
    _currenValue.text = [[NSString stringWithFormat:@"%.0f",_currenValueInt] stringByAppendingString:_unit];

}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (IBAction)saveEvent:(id)sender {
    [[NSUserDefaults standardUserDefaults] setFloat:_currenValueInt forKey:UserDataXyUpperLimit];
    _action(_currenValueInt);
    [self backTo];
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
